package com.diankangwo.factory.service.impl;

import com.diankangwo.factory.dao.TdCommodityMapper;
import com.diankangwo.factory.entity.TdCommodity;
import com.diankangwo.factory.service.TdCommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service("TdCommodityService")
public class TdCommodityServiceImpl implements TdCommodityService {

    @Autowired
    private TdCommodityMapper tdCommodityMapper;

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    @Transactional
    public int deleteByPrimaryKey(Integer id) {
        return tdCommodityMapper.deleteByPrimaryKey(id);
    }

    /**
     * 增加
     * @param record
     * @return
     */
    @Override
    @Transactional
    public int insert(TdCommodity record) {
        return tdCommodityMapper.insert(record);
    }

    /**
     * 增加返回int
     * @param record
     * @return
     */
    @Override
    @Transactional
    public int insertSelective(TdCommodity record) {
        return tdCommodityMapper.insertSelective(record);
    }

    /**
     * 按ID 查询
     * @param id
     * @return
     */
    @Override
    public TdCommodity selectByPrimaryKey(Integer id) {
        return tdCommodityMapper.selectByPrimaryKey(id);
    }

    /**
     * 更新返回int
     * @param record
     * @return
     */
    @Override
    @Transactional
    public int updateByPrimaryKeySelective(TdCommodity record) {
        return tdCommodityMapper.updateByPrimaryKeySelective(record);
    }

    /**
     * 按主见ID更新 返回int
     * @param record
     * @return
     */
    @Override
    @Transactional
    public int updateByPrimaryKey(TdCommodity record) {
        return tdCommodityMapper.updateByPrimaryKey(record);
    }

    /**
     * 按名称查询
     * @param commodityName
     * @return
     */
    @Override
    public List<TdCommodity> queryByName(String commodityName) {
        return tdCommodityMapper.queryByName(commodityName);
    }

    /**
     * 按 saleshannels查询
     * @param saleshannels
     * @return
     */
    @Override
    public List<TdCommodity> queryBySaleshannels(String saleshannels) {
        return tdCommodityMapper.queryBySaleshannels(saleshannels);
    }

    /**
     * 分页查询
     * @param map
     * @return
     */
    @Override
    public List<TdCommodity> queryList(Map<String, Object> map) {
        return tdCommodityMapper.queryList(map);
    }

    /**
     * 查询总数
     * @param map
     * @return
     */
    @Override
    public int queryTotal(Map<String, Object> map) {
        return tdCommodityMapper.queryTotal(map);
    }

    /**
     * 按二级分类查询总数
     * @param classid
     * @return
     */
    @Override
    public int queryTotalByClass(int classid) {
        return tdCommodityMapper.queryTotalByClass(classid);
    }

    /**
     * 保存
     * @param commodity
     */
    @Override
    @Transactional
    public void save(TdCommodity commodity) {
        tdCommodityMapper.save(commodity);
    }

    @Override
    @Transactional
    public int save2(TdCommodity commodity) {
        return tdCommodityMapper.save2(commodity);
    }

    /**
     * 更新
     * @param commodity
     */
    @Override
    @Transactional
    public void update(TdCommodity commodity) {
        tdCommodityMapper.update(commodity);
    }

    /**
     * 批量删除
     * @param commodityIds
     */
    @Override
    @Transactional
    public void deleteBatch(int[] commodityIds) {
        tdCommodityMapper.deleteBatch(commodityIds);
    }

    /**
     * 按厂家ID 查询
     * @param factoryId
     * @return
     */
    @Override
    public List<TdCommodity> queryByFactoryId(int factoryId) {
        return tdCommodityMapper.queryByFactoryId(factoryId);
    }

    /**
     * 按厂家ID查询总数
     * @param factoryId
     * @return
     */
    @Override
    public int querybyTotalByFactoryId(int factoryId) {
        return tdCommodityMapper.querybyTotalByFactoryId(factoryId);
    }

    /**
     * 按一级分类ID查询
     * @param typeId
     * @return
     */
    @Override
    public List<TdCommodity> queryByTypeId(int typeId) {
        return tdCommodityMapper.queryByTypeId(typeId);
    }

    /**
     * 按二级ID分类查询
     * @param classId
     * @return
     */
    @Override
    public List<TdCommodity> queryByClassId(int classId) {
        return tdCommodityMapper.queryByClassId(classId);
    }

    /**
     * 按三级分类ID 查询
     * @param speId
     * @return
     */
    @Override
    public List<TdCommodity> queryBySpeId(int speId) {
        return tdCommodityMapper.queryBySpeId(speId);
    }
}
